package com.learn.training.multithread.chapter12.demo2;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        ExecutorService es = Executors.newVirtualThreadPerTaskExecutor();
        System.out.println("main thread: " + Thread.currentThread().getName());
        for (int i = 0; i < 100000; i++) {
            System.out.println("i  :  " + i);
            es.submit(() -> {
                System.out.println("virtual service running");
                Thread.sleep(1000);
                return 0;
            });
        }
        es.close();

//        Thread.sleep(1000000);
    }
}

